
public class DiceRoll {

	public int [] _dice = new int[5];
	private boolean [] _hold = new boolean[5];
	
	public DiceRoll() {
		for (int i=0; i<5; i++) {
			 _dice[i] = YahtzeeGame.rand.nextInt(6) + 1;
		}
	}

	public DiceRoll(int [] dice) {
		System.arraycopy(dice,0,_dice,0,5);
	}

	public void rollAgain() {
		for (int i=0; i<5; i++) {
			if (!_hold[i]) {
				 _dice[i] = YahtzeeGame.rand.nextInt(6) + 1;
			}
		}
	}

	public void hold(int i) {
		_hold[i] = true;
	}

	public void free(int i) {
		_hold[i] = false;
	}

	public void freeAll() {
		for (int i=0; i<5; i++) free(i);
	}

	public void holdfree (boolean [] h) {
		for (int i=0; i<5; i++) {
			_hold[i] = h[i];
		}
	}

	public String toString() {
		String rez = "";
		for (int i=0;i<5;i++) {
			if (_hold[i]) {
				rez += " (" + _dice[i] + ")";
			} else {
				rez += "  " + _dice[i] + " ";
			}
		}
		return rez;
	}

}
	
